package jacky.com.androidtestdemo.ui.activity;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jacky.com.androidtestdemo.R;

public class List_01 extends ListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_list_01);

        SimpleAdapter sa = new SimpleAdapter(this, getDate(),
                R.layout.list_01_item,
                new String[]{"title", "info", "img"},
                new int[]{R.id.title, R.id.info, R.id.img});
        setListAdapter(sa);
    }


    private List<Map<String, Object>> getDate() {
        List<Map<String, Object>> list = new ArrayList<>();

        Map<String, Object> map = new HashMap<>();
        map.put("title", "G1");
        map.put("info", "google 1");
        map.put("img", R.drawable.a01);
        list.add(map);

        map = new HashMap<>();
        map.put("title", "G2");
        map.put("info", "google 2");
        map.put("img", R.drawable.a02);
        list.add(map);

        map = new HashMap<>();
        map.put("title", "G3");
        map.put("info", "google 3");
        map.put("img", R.drawable.a03);
        list.add(map);

        return list;
    }
}
